﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;

namespace SharingCenter.Web.Classes.ServiceLayer
{
    public interface IUnitOfWorkDataStore
    {
        object this[string key] { get; set; }
    }

    public static class UnitOfWorkHelper
    {
        public static IUnitOfWorkDataStore CurrentDataStore;
    }

    internal static class MyDataContextHelper
    {
        public static scDataContext CurrentContext
        {
            get
            {
                if (UnitOfWorkHelper.CurrentDataStore["MyDomainDataContext"] == null)
                {
                    UnitOfWorkHelper.CurrentDataStore["MyDomainDataContext"]
                        = new scDataContext(System.Configuration.ConfigurationManager.ConnectionStrings["websiteConnectionString"].ConnectionString);
                }
                return (scDataContext)UnitOfWorkHelper.CurrentDataStore["MyDomainDataContext"];
            }
        }
    }
}